package com.crud.project.service;

import com.crud.project.dao.IPermissionDao;
import com.crud.project.po.Permission;
import com.crud.project.po.Role;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PermissionService implements IPermissionDao {
    @Autowired
    private IPermissionDao iPermissionDao;
    @Override
    public List<Permission> findAllPermission() {
        List<Permission>permissionList=iPermissionDao.findAllPermission();
        return permissionList;
    }

    @Override
    public void insertPermission(Permission permission) {
        iPermissionDao.insertPermission(permission);
    }

    @Override
    public void deletePermissionById(Long id) {
        iPermissionDao.deletePermissionById(id);
    }

    @Override
    public Permission findAllPermissionById(Long id) {
       Permission permission= iPermissionDao.findAllPermissionById(id);
       return permission;
    }

    @Override
    public String findPermissionNameById(Long id) {
        return iPermissionDao.findPermissionNameById(id);
    }

    @Override
    public void updatePermission(Permission permission) {
        iPermissionDao.updatePermission(permission);
    }

    public void deletePermissionByRoleId(Long id) {
        iPermissionDao.deletePermissionByRoleId(id);
    }


    @Override
    public List<Permission> findPermissionList() {
        List<Permission>permissionList=iPermissionDao.findPermissionList();
        return permissionList;
    }


    public void insertPermissionById(Long role_id, Long permission_id) {
        iPermissionDao.insertPermissionById(role_id,permission_id);
    }


    public List<String> findPermissionListByRoleId(Long id) {
        List<String> permission=iPermissionDao.findPermissionListByRoleId(id);
        return permission;
    }


}
